#!/bin/bash

bin=`dirname "${BASH_SOURCE-$0}"`
bin=`cd $bin; cd ..; pwd`
PRJ_HOME=$bin

LOG_HOME=$PRJ_HOME/logs

if [ ! -d $LOG_HOME ]; then
    mkdir -p $LOG_HOME
fi

CLASSPATH=$PRJ_HOME/conf

for f in $PRJ_HOME/lib/*.jar; do
  if [ "$CLASSPATH" ]; then
    CLASSPATH=$CLASSPATH:$f
  fi
done

for f in $PRJ_HOME/dist/*.jar; do
  if [ "$CLASSPATH" ]; then
    CLASSPATH=$CLASSPATH:$f
  fi
done

#JAVA_OPTS="-Dlogging.home=$LOG_HOME -Xmx384M -Xms384M -Xmn128M -XX:SurvivorRatio=8 -XX:-UseAdaptiveSizePolicy -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:$LOG_HOME/webcase.gc -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_HOME}"
JAVA_OPTS="-Dlogging.home=$LOG_HOME -Xmx384M -Xms384M -Xmn228M -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:$LOG_HOME/webcase.gc -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_HOME}"

java -classpath $CLASSPATH $JAVA_OPTS cn.com.tiza.spiro.jvm.gc.optimization.WebCase > $LOG_HOME/app.out &